package com.dlc.commonlibrary.dialog;

import android.content.Context;
import android.support.v7.app.AlertDialog;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import com.dlc.commonlibrary.R;

/**
 * Created by Administrator on 2017-08-28.
 * 提示
 */

public class WelcomeDialog {

    TextView cancle;
    TextView sure;
    TextView tv_content;
    TextView title;
    private Context context;
    private OnCallBack onCallBack;
    private String content;
    private Boolean isShow;

    public WelcomeDialog(Context context,String content,Boolean isShow) {
        this.context = context;
        this.content = content;
        this.isShow = isShow;
        DialogInit();
    }

    private void DialogInit() {

        final AlertDialog.Builder Builder =
                new AlertDialog.Builder(context, R.style.DialogHint);
        View view = LayoutInflater.from(context).inflate(R.layout.dialog_welcome, null);
        Builder.setView(view);
        cancle = (TextView) view.findViewById(R.id.cancle);
        sure = (TextView)view.findViewById(R.id.sure);
        tv_content = (TextView) view.findViewById(R.id.content);
        title = (TextView) view.findViewById(R.id.title);
        if (!isShow) {
            title.setVisibility(View.GONE);
        }
        tv_content.setText(content);
        final AlertDialog dialog = Builder.show();
        cancle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        sure.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (onCallBack != null){
                    onCallBack.sure();
                }
                dialog.dismiss();
            }
        });


    }


    public void setOnCallBackListener(OnCallBack onCallBack) {
        this.onCallBack = onCallBack;
    }

    public interface OnCallBack {
        public void sure();//确定

    }
}
